<template>
    <div class="data-config-container">
        <el-tabs v-model="activeTab" class="config-tabs" type="border-card">
            <!-- 模块1: 订单占比图数据配置 -->
            <el-tab-pane label="订单占比图数据配置" name="orderRatio">
                <module1 ref="module1Ref"></module1>
            </el-tab-pane>

            <!-- 模块2: 过去24H无人车频次 -->
            <el-tab-pane label="过去24H无人车频次" name="unmannedCarFreq">
                <module2 ref="module2Ref"></module2>
            </el-tab-pane>

            <!-- 模块3: 共享运力数据配置 -->
            <el-tab-pane label="共享运力数据配置" name="sharedCapacity">
                <module3 ref="module3Ref"></module3>

            </el-tab-pane>

            <!-- 模块4: 站点表格数据配置 -->
            <el-tab-pane label="站点表格数据配置" name="siteTable">
                <module4 ref="module4Ref"></module4>

            </el-tab-pane>

            <!-- 模块5: 运行时控 -->
            <el-tab-pane label="运行时控" name="assetTotal">

                <module5 ref="module5Ref"></module5>

            </el-tab-pane>

            <!-- 模块6: 车辆状态 -->
            <el-tab-pane label="车辆状态" name="vehicleStatus">
                <module6 ref="module6Ref"></module6>

            </el-tab-pane>

            <!-- 模块7: 地图标点配置 -->
            <el-tab-pane label="地图标点配置" name="map">
                <!-- <module7 ref="module7Ref"></module7> -->
                <module8 ref="module8Ref"></module8>

            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Location, Check } from '@element-plus/icons-vue'
import { updateDataClassify, getDataClassifyDetail } from '@/api/port'

import module1 from '@/components/shared-capacity/module1.vue'
import module2 from '@/components/shared-capacity/module2.vue'
import module3 from '@/components/shared-capacity/module3.vue'
import module4 from '@/components/shared-capacity/module4.vue'
import module5 from '@/components/shared-capacity/module5.vue'
import module6 from '@/components/shared-capacity/module6.vue'
import module7 from '@/components/shared-capacity/module7.vue'
import module8 from '@/components/shared-capacity/module8.vue'




const module1Ref = ref<InstanceType<typeof module1>>()
const module2Ref = ref<InstanceType<typeof module2>>()
const module3Ref = ref<InstanceType<typeof module3>>()
const module4Ref = ref<InstanceType<typeof module4>>()
const module5Ref = ref<InstanceType<typeof module5>>()
const module6Ref = ref<InstanceType<typeof module6>>()
const module7Ref = ref<InstanceType<typeof module7>>()
const module8Ref = ref<InstanceType<typeof module8>>()



// 当前激活的标签页
const activeTab = ref('orderRatio')
const moduleDetail = ref({
    module1: {},
    module2: {},
    module3: {},
    module4: {},
    module5: {},
    module6: {},
    module7: {},

})

const getDetail = async () => {
    const res = await getDataClassifyDetail({
        id: 5
    })
    console.log(res)
    moduleDetail.value = res
    console.log(moduleDetail.value)
    module1Ref.value?.init(moduleDetail.value.module1)
    module2Ref.value?.init(moduleDetail.value.module2)
    module3Ref.value?.init(moduleDetail.value.module3)
    module4Ref.value?.init(moduleDetail.value.module4)
    module5Ref.value?.init(moduleDetail.value.module5)
    module6Ref.value?.init(moduleDetail.value.module6)
    module7Ref.value?.init(moduleDetail.value.module7)
    module8Ref.value?.init(moduleDetail.value.module8)

}




onMounted(() => {
    getDetail()

})
</script>

<style >
.data-config-container {
    padding: 20px;
    background: #f5f7fa;
    min-height: 100vh;
}

.config-tabs {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.tab-content {
    padding: 30px;
}

.config-form {
    max-width: 1200px;
}

.save-button-container {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e4e7ed;
}

.save-button-container .el-button {
    padding: 12px 40px;
    font-size: 14px;
}

:deep(.el-tabs__header) {
    margin: 0;
}

:deep(.el-tabs__nav-wrap) {
    padding: 0 20px;
}

:deep(.el-tabs__item) {
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
}

:deep(.el-tabs__content) {
    padding: 0;
}

:deep(.el-form-item) {
    margin-bottom: 20px;
}

:deep(.el-input) {
    width: 100%;
}

:deep(.el-select) {
    width: 100%;
}

/* 表单头部样式 */
.form-header {
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    text-align: center;
}

.form-header h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
}

.form-description {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.5;
}

/* 优化按钮样式 */
.save-button-container .el-button {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.save-button-container .el-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(64, 158, 255, 0.3);
}

/* 输入框优化 */
:deep(.el-input__wrapper) {
    border-radius: 6px;
    transition: all 0.3s ease;
}

:deep(.el-input__wrapper:hover) {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

:deep(.el-form-item__label) {
    font-weight: 500;
    color: #303133;
}

/* 地图标点列表样式 */
.map-points-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4e7ed;
}

.map-points-header h3 {
    margin: 0;
    color: #303133;
    font-size: 18px;
    font-weight: 600;
}

/* 地图标点弹窗样式 */
.point-dialog .dialog-content {
    display: flex;
    gap: 30px;
}

.point-dialog .form-section {
    flex: 1;
    min-width: 300px;
}

.point-dialog .map-section {
    flex: 1;
    min-width: 300px;
}

.point-dialog h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.map-placeholder {
    height: 300px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.map-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="%23dee2e6" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>') repeat;
    opacity: 0.3;
}

.map-tips {
    text-align: center;
    z-index: 1;
    position: relative;
}

.map-tips .el-icon {
    font-size: 48px;
    color: #6c757d;
    margin-bottom: 16px;
}

.map-tips p {
    margin: 8px 0;
    color: #6c757d;
    font-size: 14px;
}

.map-tips .el-button {
    margin-top: 16px;
}

/* 图表数据配置样式 */
.chart-data-section {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid #e4e7ed;
    border-radius: 8px;
    background-color: #fafafa;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4e7ed;
}

.section-header h4 {
    margin: 0;
    color: #303133;
    font-size: 16px;
    font-weight: 600;
}

.chart-data-list {
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
}

.chart-item {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #e4e7ed;
    border-radius: 6px;
    transition: all 0.3s;
}

.chart-item:hover {
    border-color: #409eff;
    box-shadow: 0 2px 8px rgba(64, 158, 255, 0.1);
}

.chart-item-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.chart-item-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-item-field label {
    min-width: 70px;
    font-size: 14px;
    color: #606266;
    font-weight: 500;
}

.chart-item-actions {
    margin-left: auto;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #909399;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
}

/* 滚动条样式 */
.chart-data-list::-webkit-scrollbar {
    width: 6px;
}

.chart-data-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chart-data-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chart-data-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
</style>